import axios from '@/utils/axios'

const addSpApi = '/sp_admin/sp_mgr/add' // 新增
const updateSpApi = '/sp_admin/sp_mgr/update' // 编辑
const spPageApi = '/sp_admin/sp_mgr/list' // 列表
const spDetailApi = '/sp_admin/sp_mgr/detail' // 详情
const spBaseInfoApi = '/sp_admin/platform/sp_info' // 基础信息
const spTreeApi = '/sp_admin/platform/sp_tree' // sp tree
const changeSpStatusApi = '/sp_admin/sp_mgr/change_status' // 状态
const resetSpPwApi = '/sp_admin/sp_mgr/reset_pw' // 密码
const zfbMercQueryApi = '/sp_admin/aliConf/queryAliConf'
const zfbMercUpdateApi = '/sp_admin/aliConf/updateAliConf'

/**
 * @desc 新增
 */
export const addSp = ({ data }) => {
  return axios.post(addSpApi, data)
}

/**
 * @desc 更新
 */
export const updateSp = ({ data }) => {
  return axios.post(updateSpApi, data)
}

/**
 * @desc 列表
 */
export const spPage = ({ data }) => {
  return axios.post(spPageApi, data)
}

/**
 * @desc 详情
 */
export const spDetail = ({ params }) => {
  return axios({
    url: spDetailApi,
    method: 'get',
    params: params
  })
}

/**
 * @desc 基础信息
 */
export const spBaseInfo = ({ params }) => {
  return axios({
    url: spBaseInfoApi,
    method: 'post',
    params: params
  })
}

/**
 * @desc sp tree
 */
export const spTree = ({ params } = { includeTop: 0 }) => {
  return axios({
    url: spTreeApi,
    method: 'get',
    params: params
  })
}

/**
 * @desc 状态
 */
export const changeSpStatus = ({ data }) => {
  return axios.post(changeSpStatusApi, data)
}

/**
 * @desc 密码
 */
export const resetSpPw = ({ data }) => {
  return axios.post(resetSpPwApi, data)
}
/** ************************** 支付宝配置相关 ****************************/
/**
 * @desc 支付宝直连商户配置查询
 */
export const zfbMercQuery = (data) => {
  return axios({
    url: zfbMercQueryApi,
    method: 'get',
    params: data,
    hideMessage: true
  })
}
/**
 * @desc 支付宝直连商户配置新增或修改
 */
export const zfbMercUpdate = (data) => {
  return axios({
    url: zfbMercUpdateApi,
    method: 'post',
    data,
    hideMessage: true
  })
}
